import logging

import pytest

from api.ihrm_login_api import IhrmLoginApi
from common.assert_tools import common_assert
from common.logging_use import init_log_config
from common.read_json_file import read_json_data
from config import BASE_DIR


class TestIhrmLogin(object):
    init_log_config(BASE_DIR+"/log/sh_083102.log",interval_data=3,backup_count=5)
    # 读取json文件，读取[(),(),()]格式数据
    data = read_json_data(BASE_DIR + "/data/login.json")

    @pytest.mark.parametrize("desc,req_data,status_code,success,code,message",data)
    # 定义通用方法--测试ihrm登录接口
    def test_login(self,desc,req_data,status_code,success,code,message):
        # 调用自己封装的api，获取响应信息
        resp = IhrmLoginApi.login(req_data)
        # 打印查看
        # print(desc,":",resp.json())
        logging.info(resp.json())
        # 断言
        common_assert(resp,status_code,success,code,message)